<?php 
class userModel extends X_mysql_table{
    public $table = "user";
    public $idField = "u_id";
    
    public function login($username, $password) {
        return $this->where("u_username = ?", $username)
                    ->where("u_active = 1")
                    ->where("u_password IN (?)", array($password, md5($password)))
                ->fetchRow();
    }
    
    public function getAll(){
        return $this->select()->where("u_active = 1")->fetchAll(); // Will return an array of objects of type userModelRow. Access data like this : $arrayOfObjects[INDEX]->COLUMNNAME
        // return $this->fetchAll(); // This line does the same as the above if you do not need any condition and just want to fetch ALL rows.
    }
    
    public function get($id) {
        return $this->fetchRow($id); // This line returns one row (the one with the id $id) as an object of type userModelRow
    }
    
    
}
class userModelRow extends X_mysql_row{
    
    // Optional setters and getters that will be called automatically to convert data to and from mysql database. _set_COLUMNNAME, _get_COLUMNNAME
    /* // Example for timestamp fields
    public function _set_date($timestamp) {
        return date("Y-m-d H:i:s", $timestamp); // returns the date formatted for insert in mysql timestamp
    }
    public function _get_date($date) {
        return date("l, F j, Y", strtotime($date)); // returns Monday, February 4, 2013
    }
    */
    
}